package com.ojoin.trade.supplyloan_core.web.dao.impl;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.exception.DaoException;
import com.ojoin.trade.common.web.dao.impl.BaseDaoImpl;
import com.ojoin.trade.supplyloan_core.web.dao.TbSlStattaskRunlogDao;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlStattaskRunlog;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Repository;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15-10-22
 * Time: 上午11:46
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class TbSlStattaskRunlogDaoImpl extends BaseDaoImpl<TbSlStattaskRunlog> implements TbSlStattaskRunlogDao {
    @Override
    public void insertTbSlStattaskRunlog(TbSlStattaskRunlog stattaskRunlogvo) throws BusinessException {
        String mapMethodName ="insert";
        try{
            this.sqlSessionTemplate.insert(getSqlName(mapMethodName),stattaskRunlogvo);
        }catch (Exception e) {
            throw new DaoException(String.format("插入商户日抓取定时任务信息表出错！joinid==="+stattaskRunlogvo.getIdOfTbMerchantUser()+"语句：%s",
                    getSqlName(mapMethodName)), e);
        }
    }

    @Override
    public TbSlStattaskRunlog queryStattaskRunlogByJoinidanddate(int join_id, String check_date) throws BusinessException {
        String methodName="selectByJoinidanddate";
        HashMap<String,Object> parammap=new HashMap<String, Object>();
        parammap.put("id_of_tb_merchant_user",join_id);
        parammap.put("check_date",check_date);
        try {
            List list = this.sqlSessionTemplate.selectList(getSqlName(methodName),
                    parammap);
            if (list != null && list.size() >0)
                return (TbSlStattaskRunlog) list.get(0);
        } catch (Exception e) {
            throw new DaoException(String.format("根据商户的joinid查询商户日定时任务运行情况信息表出错->" + join_id + "出错！语句：%s",
                    getSqlName(methodName)), e);
        }
        return null;
    }
}
